package com.example.scugroup8.socket;

import org.springframework.stereotype.Service;

import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.net.Socket;

//@Service
public class ServerSocket {
    public ServerSocket() throws IOException {
        //指定端口
        Integer port = 9999;
        //注册服务端的socket对象
        java.net.ServerSocket serverSocket = new java.net.ServerSocket(port);
        while (true) {
            //监听-阻塞
            Socket accept = serverSocket.accept();
            //创建并启动线程
            new ServerThread(accept).start();
        }
    }
}
